package QRCG;

import junit.framework.*;

public class TestUtil extends TestCase {
	
	private Util utilities;
	
	protected void setUp(){
		utilities = new Util();
	}
	
	public void testHasTextContent() {
		String nullString = null;
		assertFalse(utilities.hasTextContent(nullString));
		String emptyString = "";
		assertFalse(utilities.hasTextContent(emptyString));
		String spaceString = "     ";
		assertFalse(utilities.hasTextContent(spaceString));
		String whitespaceString = " " + '\n' + '\t';
		assertFalse(utilities.hasTextContent(whitespaceString));
		String fullString = "abcde";
		assertTrue(utilities.hasTextContent(fullString));
		String spaceBeforeString = "   abcde";
		assertTrue(utilities.hasTextContent(spaceBeforeString));
		String spaceAfterString = "abcde   ";
		assertTrue(utilities.hasTextContent(spaceAfterString));
		String spaceBeforeAndAfterString = "   abcde   ";
		assertTrue(utilities.hasTextContent(spaceBeforeAndAfterString));
	}

	public void testGetMD5Hash() {
		String emptyString = "";
		assertEquals("d41d8cd98f00b204e9800998ecf8427e",utilities.getMD5Hash(emptyString));
		String fullString = "abcde";
		assertEquals("ab56b4d92b40713acc5af89985d4b786",utilities.getMD5Hash(fullString));
	}
	
	public static void main(String args[]) {
	    junit.textui.TestRunner.run(TestUtil.class);
	}
}
